﻿using System;
using NUnit.Framework;

namespace Medianamik.Core
{
    [TestFixture]
    public class DataTypeTest
    {
        [Test]
        public void DataTypesWithTheSameIdShouldBeEqual()
        {
            Guid id = Guid.NewGuid();
            var dataType1 = new DataType(id, "int", false, false);
            var dataType2 = new DataType(id, "int", false, false);
            var dataType3 = new DataType(Guid.NewGuid(), "int", false, false);

            Assert.That(dataType1.Equals(dataType2));
            Assert.That(!dataType1.Equals(dataType3));
        }

        [Test]
        public void DataTypes_with_the_same_ID_should_have_same_HashCode()
        {
            Guid id = Guid.NewGuid();
            var dataType1 = new DataType(id, "int", false, false);
            var dataType2 = new DataType(id, "int", false, false);
            var dataType3 = new DataType(Guid.NewGuid(), "int", false, false);

            Assert.That(dataType1.GetHashCode() , Is.EqualTo(dataType2.GetHashCode()));
            Assert.That(dataType1.GetHashCode(), Is.Not.EqualTo(dataType3.GetHashCode()));
            
        }
    }
}
